/**
 * Created by hxsd on 2016/7/8.
 */

angular.module("mainApp").controller("picCtrl",function($scope,$ionicModal){
    $scope.changePicBg=function(){
        $(".pic-card").each(function dd(){
            $(this).css("backgroundPosition","0px "+(10-parseInt($(this).offset().top)/3)+"px")
        })
    };
    $scope.changePicBg();
    $ionicModal.fromTemplateUrl("beautifulPic-modal.html",{
        scope: $scope,      // 默认使用的是$rootScope，因些执行这一句，改为使用$scope
        animation: 'slide-in-up'    // 模态窗口出现的动画效果
    }).then(function(modal){
        $scope.modal = modal;       // 在$scope中保存创建好的模态窗口
    });
    $scope.openModal = function(){
        $scope.modal.show();    // 显示模态窗口
    };

    $scope.closeModal = function(){
        $scope.modal.hide();    // 隐藏模态窗口
    };
    $scope.$on('$destroy', function() {
        $scope.modal.remove();  // 释放内存
    });

    // Execute action on hide modal
    $scope.$on('modal.hidden', function() {
        // Execute action
    });
    // Execute action on remove modal
    $scope.$on('modal.removed', function() {
        // Execute action
    });

});